package com.ayoka.parenting.adapter;

import android.graphics.Color;
import android.graphics.drawable.GradientDrawable;
import android.view.ViewGroup;

import com.ayoka.parenting.R;
import com.ayoka.parenting.bean.GrownPathBean;
import com.jincp.common.brvah.BaseQuickAdapter;
import com.jincp.common.brvah.BaseViewHolder;


/**
 * @ProjectName: ayoka7.
 * @ClassName: CourseClassroomMemberAdapter.
 * @Description: .
 * @Author: jincp.
 * @CreateDate: 2019/8/6 21:15.
 */

public class GrownPathAdapter extends BaseQuickAdapter<GrownPathBean, BaseViewHolder> {

    public static String[] colors = {"#FFF5CB","#E7F1E8","#D3EDFB"};

    public GrownPathAdapter() {
        super(R.layout.item_grown_path);
    }

    @Override
    protected void convert(BaseViewHolder holder, GrownPathBean item) {
        ViewGroup parent = holder.getView(R.id.layout_meditation_container);
        parent.setBackground(getRandimBackground(holder.getLayoutPosition()));
        if (item.Meditation != null) {
            holder.setText(R.id.tv_group_title, item.Meditation.GroupTitle)
                    .setText(R.id.tv_title, item.Meditation.Title)
                    .setText(R.id.tv_date, item.LastUpdate);
        }
        if (item.IsComment == 0) {
            holder.setText(R.id.btn_operate, R.string.wait_comment);
        } else {
            holder.setText(R.id.btn_operate, R.string.commented);
        }
    }

    private GradientDrawable getRandimBackground(int index){
        GradientDrawable background = new GradientDrawable();
        background.setCornerRadius(20);
        background.setColor(Color.parseColor(colors[index%3]));
        return background;
    }
}
